<template>
	<div>
		<el-drawer title="" :visible.sync="drawer" :direction="direction" :before-close="handleClose" custom-class="drawer-info">
			<div class="info-item">
				<h5 class="from-title">基本信息</h5>
				<div class="form-item">
					<label class="form-item-label">课程分类:</label>
					<div class="form-item-content">{{ objInfo.classifyIdName }}</div>
				</div>
				<div class="form-item">
					<label class="form-item-label">课程名称:</label>
					<div class="form-item-content">{{ objInfo.courseName }}</div>
				</div>
				<div class="form-item">
					<label class="form-item-label">封面图片:</label>
					<div class="form-item-content">
						<img v-if="objInfo.coverImg" :src="objInfo.coverImg" style="width: 100px; height: 100px" />
					</div>
				</div>
				<div class="form-item">
					<label class="form-item-label">课程简介:</label>
					<div class="form-item-content">{{ objInfo.courseSynopsis }}</div>
				</div>
				<div class="form-item">
					<label class="form-item-label">课程状态:</label>
					<div class="form-item-content">{{ objInfo.courseStatusName }}</div>
				</div>
				<div class="form-item">
					<label class="form-item-label">开班状态:</label>
					<div class="form-item-content" v-if="objInfo.classStatus == 1">启用</div>
					<div class="form-item-content" v-else>禁用</div>
				</div>
				<div class="form-item">
					<label class="form-item-label">是否推荐:</label>
					<div class="form-item-content" v-if="objInfo.isRecommend == 1">启用</div>
					<div class="form-item-content" v-else>禁用</div>
				</div>
				<div class="form-item">
					<label class="form-item-label">排序:</label>
					<div class="form-item-content">{{ objInfo.sort }}</div>
				</div>
			</div>
		</el-drawer>
	</div>
</template>
<script>
import { studycourseInfo } from "@/api/study/course/studycourse.js"
import { enumList, urlList } from "@/api/public.api.js"
export default {
	data() {
		return {
			drawer: true,
			direction: "rtl",
			objInfo: {},
			CourseStatusList: [],
			YesNoList: [],
			classifyIdList: [],
		}
	},
	created() {},
	methods: {
		queryEnumList() {
			this.CourseStatusList = []
			enumList("CourseStatus", "").then(resp => {
				if (resp.code == 0) {
					this.CourseStatusList = resp.data
				}
			})
			this.YesNoList = []
			enumList("YesNo", "").then(resp => {
				if (resp.code == 0) {
					this.YesNoList = resp.data
				}
			})
		},
		queryUrlList() {
			this.classifyIdList = []
			urlList("/study/course/studyCourseClassify/list").then(resp => {
				if (resp.code == 0) {
					if (resp.data) {
						resp.data.forEach(item => {
							this.classifyIdList.push({ code: item.id, name: item.name })
						})
					}
				}
			})
		},
		init(id) {
			this.queryEnumList()
			this.queryUrlList()
			if (id) {
				studycourseInfo(id).then(res => {
					this.objInfo = res.data
					let classifyIdObj = this.classifyIdList.find(item => {
						return item.code == this.objInfo.classifyId
					})
					this.objInfo.classifyIdName = classifyIdObj ? classifyIdObj.name : ""
					let courseStatusObj = this.CourseStatusList.find(item => {
						return item.code == this.objInfo.courseStatus
					})
					this.objInfo.courseStatusName = courseStatusObj ? courseStatusObj.name : ""
				})
			}
			this.drawer = true
		},
		// 关闭抽屉
		handleClose(done) {
			done()
		},
	},
}
</script>
<style scoped>
.from-title {
	margin-bottom: 20px;
	padding: 0 20px 20px 20px;
	font-size: 16px;
	color: #17233d;
	border-bottom: 1px solid #eee;
}
.info-item {
	margin-bottom: 40px;
}

.form-item {
	margin-bottom: 20px;
	font-size: 14px;
}
.form-item-label {
	text-align: right;
	float: left;
	width: 25%;
}
.form-item-content {
	margin-left: 30%;
	width: 70%;
}
</style>
